package com.xuecheng.content.service.impl;

import com.xuecheng.content.model.dto.CoursePreviewDTO;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.ICourseBaseService;
import com.xuecheng.content.service.ICoursePreviewService;
import com.xuecheng.content.service.ICourseTeacherService;
import com.xuecheng.content.service.ITeachPlanService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @description: 课程预览服务实现类
 * @author 勾新杰
 * @version 1.0
 * @date 2025/2/16 21:47
 */
@Service
@RequiredArgsConstructor
public class ICoursePreviewServiceImpl implements ICoursePreviewService {

    /**
     * 课程基本信息服务
     */
    private final ICourseBaseService courseBaseService;

    /**
     * 课程计划信息服务
     */
    private final ITeachPlanService teachPlanService;

    /**
     * 课程师资信息服务
     */
    private final ICourseTeacherService courseTeacherService;

    /**
     * 获取课程预览信息
     *
     * @param courseId 课程id
     * @return 课程预览信息
     */
    @Override
    public CoursePreviewDTO preview(Long courseId) {
        return CoursePreviewDTO.builder()
                .courseBase(courseBaseService.getCourseBaseInfoById(courseId))
                .teachplans(teachPlanService.queryTreeNodes(courseId))
                .teachers(courseTeacherService.lambdaQuery().eq(CourseTeacher::getCourseId, courseId).list())
                .build();
    }
}
